package com.happly.happlycloud.controller.backend;

import com.happly.happlycloud.common.ServerResponse;
import com.happly.happlycloud.service.IMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/manage/message")
@Api("留言信息管理")
public class MessageManageController {

    @Autowired
    private IMessageService iMessageService;


    @RequestMapping("delete_msg.do")
    @ApiOperation("添加")
    public ServerResponse deleteMessage(HttpServletRequest httpServletRequest, Integer messageId) {
        return iMessageService.deleteMessage(messageId);
    }

    @RequestMapping("sure_msg.do")
    @ApiOperation("添加")
    public ServerResponse suerMessage(HttpServletRequest httpServletRequest, Integer id) {
        return iMessageService.sureMessage(id);
    }

    @RequestMapping("refuse_msg.do")
    @ApiOperation("添加")
    public ServerResponse refuseMessage(HttpServletRequest httpServletRequest, Integer id) {
        return iMessageService.refuseMessage(id);
    }


    @RequestMapping("detail.do")
    @ApiOperation("添加")
    public ServerResponse getDetail(HttpServletRequest httpServletRequest, Integer messageId) {
        return iMessageService.manageMessageDetail(messageId);
    }

    @RequestMapping("list.do")
    @ApiOperation("添加")
    public ServerResponse getList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        //填充业务
        return iMessageService.getMessageList(pageNum, pageSize);
    }

    @RequestMapping("search.do")
    @ApiOperation("添加")
    public ServerResponse messageSearch(HttpServletRequest httpServletRequest, String userName, Integer messageId, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        //填充业务
        return iMessageService.searchMessage(userName, messageId, pageNum, pageSize);
    }
    @RequestMapping("searchtutor.do")
    @ApiOperation("添加")
    public ServerResponse messageSearchTutor(HttpServletRequest httpServletRequest, String userName, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        //填充业务
        return iMessageService.searchMessageTutor(userName, pageNum, pageSize);
    }

    @RequestMapping("applylist.do")
    @ApiOperation("添加")
    public ServerResponse getTutorList(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        //填充业务
        return iMessageService.getApplyMessageList(pageNum,pageSize);
    }

    @RequestMapping("applysearch.do")
    @ApiOperation("添加")
    public ServerResponse messageApplyTutor(HttpServletRequest httpServletRequest, Integer userId,Integer history,  @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        //填充业务
        return iMessageService.searchApplyMessage(userId,history,pageNum,pageSize);
    }

}
